export const msgCode = {
  SUCCESS: 1000,
  ADD_SUCCESS: 1100,
  EDIT_SUCCESS: 1200,
  DELETE_SUCCESS: 1300,
  OPERATE_SUCCESS: 1400,
  SAVE_SUCCESS: 1500,
  UPLOAD_SUCCESS: 1600,
  DOWNLOAD_SUCCESS: 1700,
  COPY_SUCCESS: 1800,
  LOGIN_SUCCESS: 1900,
  SYNC_SUCCESS: 2000,
  SYSTEM_ERROR: 500,
  USER_INVALIDATE: 430,
  TOKEN_EXPIRE: 431,
  DATA_DUPLICATE: 460,
  DATA_PROTECT: 470,
  ERROR: -1000,
  ADD_ERROR: -1100,
  EDIT_ERROR: -1200,
  DELETE_ERROR: -1300,
  OPERATE_ERROR: -1400,
  SAVE_ERROR: -1500,
  UPLOAD_ERROR: -1600,
  DOWNLOAD_ERROR: -1700,
  COPY_ERROR: -1800,
  LOGIN_ERROR: -1900,
};

export const msgContent = {
  SUCCESS: "成功",
  ADD_SUCCESS: "新增成功",
  EDIT_SUCCESS: "编辑成功",
  DELETE_SUCCESS: "删除成功",
  OPERATE_SUCCESS: "操作成功",
  SAVE_SUCCESS: "保存成功",
  UPLOAD_SUCCESS: "上传成功",
  DOWNLOAD_SUCCESS: "下载成功",
  COPY_SUCCESS: "复制成功",
  LOGIN_SUCCESS: "登录成功",
  SYNC_SUCCESS: "同步成功",
  ERROR: "失败",
  SYSTEM_ERROR: "系统维护中，请稍后再试",
  USER_INVALIDATE: "用户校验失败",
  TOKEN_EXPIRE: "由于长时间未进行任何操作，触发系统安全保护机制，需要您重新登录才可继续使用",
  DATA_DUPLICATE: "数据重复",
  DATA_PROTECT: "数据保护",
  ADD_ERROR: "新增失败",
  EDIT_ERROR: "编辑失败",
  DELETE_ERROR: "删除失败",
  OPERATE_ERROR: "操作失败",
  SAVE_ERROR: "保存失败",
  UPLOAD_ERROR: "上传失败",
  DOWNLOAD_ERROR: "下载失败",
  COPY_ERROR: "复制失败",
  LOGIN_ERROR: "登录失败",
};

export const commonString = {
  unknown: "未知",
  none: "无",
  dash: "--",
  system: '系统'
};

export const dftPadCode = {
  example: `function main(params) {
    // params: {type: "padInput", key: "startSys", value: true}
    // 判断开启系统
    if (params.key === "startSys" && params.value) {
      // 开启系统情景
      Fns.controlScene(10001);

      Output.set("progress", 0);
      // 每次间隔1s，执行20次
      Fns.interval(1, 20, () => {
        // 每次定时任务执行的回调
        Output.set("progress", Output.get("progress") + 1);  // 1s
        // 打印日志
        Fns.print("info", "current output progress:", Output.get("progress"));
      }, () => {
        // 最后一次定时任务执行的回调
        Output.set("startSys", true);  // 自动推送startSys给pad
        Fns.pushVariable(["home_page_visible"])
      })
    }

    // params: {type: "padInput", key: "callHangUp", value: true}
    // 挂断会议
    if (params.key === "callHangUp" && params.value) {
      Fns.controlDevice({
        method: "callHangUp",
        map_id: "m1001",
        params: {}
      })
    }
  }`,
  codeFunc: `function main(params) {
    // params: {type, key, value}
    switch (params.type) {
      case "padInput": {
        break;
      }
      case "status": {
        break;
      }
      default:
        break;
    }
  }`,
  propertyMap:
    `{
        "Device.{mapId}.callId_callStatus.callStatus": "callStatus",
        "Room.systemOn": "systemOn"
    }`,
  logic:
    `     void main() {
          // 获取变量
          dynamic a = getVar("1");
          if (a == null) {
              // 控制设备
            controlDevice({
              "controlId": "m120601",
              "data":{
                  "method": "setChannelPower",
                  "params": {"channel": "1", "power": "off"}
              }
            });
          }
          // 控制情景
          controlScene("10001");
          // key
          String visibleKey = "7CL577x7iLmXqHpiv-tFEGiJUO99KhlXGMWmT72AxtE0yBjiVi.visible";
          // 获取变量
          bool visible = getVar(visibleKey);
           // 获取全局变量
          dynamic globalVar = getVar("globalVar-7ewbDagdGNyYHv49N4ls39x2k97uo2dR");
          if (visible) {
            // 设置变量
            setVar(visibleKey, false);
          } else {
            setVar(visibleKey, true);
          }
        }`,
  func1:
    `{
              "controlId": "m1234",
              "data": {
                  "method": "",
                  "params": {}
                }  
            }`,
  func2:
    `{
              "controlId": "m120601",
              "data":{
                "method": "setChannelPower",
                "params": {"channel": "1", "power": "off"}
              }
            }`
};
